﻿/*  AdCom.LibraryJS.Javascript
    Developer: Nguyen Xuan Hoang
    Fpt Telecom - 48 Van Bao - Ngoc Khanh - Ba Dinh - Ha Noi
    Mobile: 84-983251124
    Email: hoangnx.fpt@gmail.com
    --------------------------------------------------------
*/
function OpenMedia(urlvalue)
{
	var WMP7;
	try
	{
		if ( navigator.appName != "Netscape" )
		{
			WMP7 = new ActiveXObject('WMPlayer.OCX');
		}
	}
	catch (error)
	{
		;
	}
	var leftPos = (screen.availWidth-230) / 2;
	var topPos = (screen.availHeight-275) / 2;
	var TorchTeWindow = window.open('','','width=230,height=275,scrollbars=no,resizable=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
	TorchTeWindow.document.open();
	var HTML = ('<html><head><title>fpt.vn - nhacso.net</title>');
	    HTML += ('<link type="text/css" href="/AdCss/PublicStyle.css" rel="stylesheet" />');
	    HTML += ('</head><body>');
	    HTML += ('<table border="0" height="250" width="210" align="center" class="tableBorder"><tr><td>');
	// Windows Media Player 7 Code
	if ( WMP7 )
	{
	    HTML +=  ('<OBJECT id="Player" height="250" width="210" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" VIEWASTEXT>');
	    HTML +=  ('<PARAM NAME="URL" VALUE="'+urlvalue+'">');
	    HTML +=  ('<PARAM NAME="rate" VALUE="1">');
	    HTML +=  ('<PARAM NAME="balance" VALUE="0">');
	    HTML +=  ('<PARAM NAME="currentPosition" VALUE="0">');
	    HTML +=  ('<PARAM NAME="defaultFrame" VALUE="">');
	    HTML +=  ('<PARAM NAME="playCount" VALUE="1">');
	    HTML +=  ('<PARAM NAME="autoStart" VALUE="1">');
	    HTML +=  ('<PARAM NAME="currentMarker" VALUE="0">');
	    HTML +=  ('<PARAM NAME="invokeURLs" VALUE="-1">');
	    HTML +=  ('<PARAM NAME="baseURL" VALUE="">');
	    HTML +=  ('<PARAM NAME="volume" VALUE="100">');
	    HTML +=  ('<PARAM NAME="mute" VALUE="0">');
	    HTML +=  ('<PARAM NAME="uiMode" VALUE="full">');
	    HTML +=  ('<PARAM NAME="stretchToFit" VALUE="0">');
	    HTML +=  ('<PARAM NAME="windowlessVideo" VALUE="0">');
	    HTML +=  ('<PARAM NAME="enabled" VALUE="-1">');
	    HTML +=  ('<PARAM NAME="enableContextMenu" VALUE="0">');
	    HTML +=  ('<PARAM NAME="fullScreen" VALUE="0">');
	    HTML +=  ('<PARAM NAME="SAMIStyle" VALUE="">');
	    HTML +=  ('<PARAM NAME="SAMILang" VALUE="">');
	    HTML +=  ('<PARAM NAME="SAMIFilename" VALUE="">');
	    HTML +=  ('<PARAM NAME="captioningID" VALUE="">');
	    HTML +=  ('</OBJECT>');
	}

	// Windows Media Player 6.4 Code
	else
	{
	    HTML +=  ('<OBJECT ID="Player"  classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ');
	    HTML +=  ('codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" ');
	    HTML +=  ('width="210" height="250"');
	    HTML +=  ('standby="Loading Microsoft Windows Media Player components..." ');
	    HTML +=  ('type="application/x-oleobject" VIEWASTEXT> ');
	    HTML +=  ('<PARAM NAME="FileName" VALUE="'+urlvalue+'">');
	    HTML +=  ('<PARAM NAME="TransparentAtStart" Value="false">');
	    HTML +=  ('<PARAM NAME="AutoStart" Value="true">');
	    HTML +=  ('<PARAM NAME="AnimationatStart" Value="false">');
	    HTML +=  ('<PARAM NAME="ShowControls" Value="false">');
	    HTML +=  ('<PARAM NAME="autoSize" Value="true">');
	    HTML +=  ('<PARAM NAME="ShowDisplay" value ="false">');
	    HTML +=  ('<PARAM NAME="displaySize" Value="0">');
	    HTML +=  ('<Embed type="application/x-mplayer2" ');
	    HTML +=  ('pluginspage= ');
	    HTML +=  ('"http://www.microsoft.com/Windows/MediaPlayer/" ');
	    HTML +=  ('src="'+urlvalue+'" ');
	    HTML +=  ('Name=MediaPlayer ');
	    HTML +=  ('transparentAtStart=0 ');
	    HTML +=  ('autostart=1 ');
	    HTML +=  ('animationAtStart=0 ');
	    HTML +=  ('autoSize=1');
	    HTML +=  ('width="210" height="250"');	
	    HTML +=  ('displaySize=0></Embed> ');
	    HTML +=  ('</OBJECT> ');
	}
	HTML += ('</td></tr>');
	HTML += ('<tr><td class="source"><a href="www.nhacso.net">Chi tiết tại http://www.nhacso.net</a></td></tr>');;
	HTML += ('</table></body></html>');
	TorchTeWindow.document.write(HTML);
	TorchTeWindow.document.close();
}
function AdWriteResource(urlvalue,typevalue,width,height,href,Cssclass)
{
    var HTML = '';
    if(typevalue=='img')
    {
        if (href!='')
            HTML = '<a href="' + href + '" title="">';
        HTML += '<img src="' + urlvalue + '" border="0" alt="" class="' + Cssclass + '"';
        if (width!=0)
            HTML += ' width="' + width + '"';
        if (height!=0)
            HTML += ' height="' + height + '"';
        HTML += ' />';
        if (href!='')
            HTML +='</a>';
    }
    else if(typevalue=='avi')
    {
	    var WMP7;
        try
        {
            if ( navigator.appName != "Netscape" )
            {
	            WMP7 = new ActiveXObject('WMPlayer.OCX');
            }
        }
        catch (error)
        {
            ;
        }
	    // Windows Media Player 7 Code
	    if ( WMP7 )
	    {
	        HTML =  '<object align="baseline" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" VIEWASTEXT class="' + Cssclass + '"';
	        if (width!=0)
                HTML += ' width="' + width + '"';
            else 
                HTML += ' width="200"';
            if (height!=0)
                HTML += ' height="' + height + '"';
            else 
                HTML += ' height="150"';
	        HTML += ' >';
	        HTML +=  ('<param name="URL" value="'+urlvalue+'" />');
	        HTML +=  ('<param name="rate" value="1" />');
	        HTML +=  ('<param name="balance" value="0" />');
	        HTML +=  ('<param name="currentPosition" value="0" />');
	        HTML +=  ('<param name="defaultFrame" value="" />');
	        HTML +=  ('<param name="playCount" value="1" />');
	        HTML +=  ('<param name="autoStart" value="0" />');
	        HTML +=  ('<param name="currentMarker" value="0" />');
	        HTML +=  ('<param name="invokeURLs" value="-1" />');
	        HTML +=  ('<param name="baseURL" value="" />');
	        HTML +=  ('<param name="volume" value="100" />');
	        HTML +=  ('<param name="mute" value="0" />');
	        HTML +=  ('<param name="uiMode" value="full" />');
	        HTML +=  ('<param name="stretchToFit" value="0" />');
	        HTML +=  ('<param name="windowlessVideo" value="0" />');
	        HTML +=  ('<param name="enabled" value="-1" />');
	        HTML +=  ('<param name="enableContextMenu" value="-1" />');
	        HTML +=  ('<param name="fullScreen" value="0" />');
	        HTML +=  ('<param name="SAMIStyle" value="" />');
	        HTML +=  ('<param name="SAMILang" value="" />');
	        HTML +=  ('<param name="SAMIFilename" value="" />');
	        HTML +=  ('<param name="captioningID" value="" />');
	        HTML +=  ('<param name="enableErrorDialogs" value="0"/>');
	        HTML +=  ('</object />');
	    }
	    // Windows Media Player 6.4 Code
	    else
	    {
	        HTML =  '<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" class="' + Cssclass + '"';
	        HTML +=  ('codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" ');
	        HTML +=  ('standby="Loading Microsoft Windows Media Player components..." ');
	        HTML +=  ('type="application/x-oleobject" VIEWASTEXT');
	        if (width!=0)
                HTML += ' width="' + width + '"';
            else 
                HTML += ' width="200"';
            if (height!=0)
                HTML += ' height="' + height + '"';
            else 
                HTML += ' height="150"';
	        HTML += ' >';
	        HTML +=  ('<param name="FileName" value="'+urlvalue+'" />');
	        HTML +=  ('<param name="TransparentAtStart" value="false" />');
	        HTML +=  ('<param name="AutoStart" value="true" />');
	        HTML +=  ('<param name="AnimationatStart" value="false" />');
	        HTML +=  ('<param name="ShowControls" value="false" />');
	        HTML +=  ('<param name="autoSize" value="true" />');
	        HTML +=  ('<param name="ShowDisplay" value ="false" />');
	        HTML +=  ('<param name="displaySize" value="0" />');
	        HTML +=  ('<embed type="application/x-mplayer2" ');
	        HTML +=  ('pluginspage= ');
	        HTML +=  ('"http://www.microsoft.com/Windows/MediaPlayer/" ');
	        HTML +=  ('src="'+urlvalue+'" ');
	        HTML +=  ('Name=MediaPlayer ');
	        HTML +=  ('transparentAtStart=0 ');
	        HTML +=  ('autostart=1 ');
	        HTML +=  ('animationAtStart=0 ');
	        HTML +=  ('autoSize=1');
	        HTML +=  ('displaySize=0');
	        if (width!=0)
                HTML += ' width="' + width + '"';
            else 
                HTML += ' width="200"';
            if (height!=0)
                HTML += ' height="' + height + '"';
            else 
                HTML += ' height="150"';
	        HTML +=  ('></embed> ');
	        HTML +=  ('</object> ');
	    }   
    }
    else if (typevalue=='swf')
    {
    	HTML =  '<object type="flash" align="baseline" border="0" classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" class="' + Cssclass + '"';
    	if (width!=0)
                HTML += ' width="' + width + '"';
            else 
                HTML += ' width="200"';
        if (height!=0)
            HTML += ' height="' + height + '"';
        else 
            HTML += ' height="150"';
        HTML += ' >';
        HTML += '<param name="_cx" value="5292" />';
        HTML += '<param name="_cy" value="3969" />';
        HTML += '<param name="FlashVars" value="5292" />';
        HTML += '<param name="Movie" value="' + urlvalue + '" />';
        HTML += '<param name="Src" value="' + urlvalue + '" />';
        HTML += '<param name="WMode" value="Window" />';
        HTML += '<param name="Play" value="-1" />';
        HTML += '<param name="Loop" value="-1" />';
        HTML += '<param name="Quality" value="High" />';
        HTML += '<param name="SAlign" value="" />';
        HTML += '<param name="Menu" value="-1" />';
        HTML += '<param name="Base" value="" />';
        HTML += '<param name="AllowScriptAccess" value="always" />';
        HTML += '<param name="Scale" value="ShowAll" />';
        HTML += '<param name="DeviceFont" value="0" />';
        HTML += '<param name="EmbedMovie" value="0" />';
        HTML += '<param name="BGColor" value="" />';
        HTML += '<param name="SWRemote" value="" />';
        HTML += '<embed src="' + urlvalue + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1"';
        if (width!=0)
            HTML += ' width="' + width + '"';
        else 
            HTML += ' width="200"';
        if (height!=0)
            HTML += ' height="' + height + '"';
        else 
            HTML += ' height="150"';
		HTML += ' quality="High">';
        HTML += '</object>';
    }
    return HTML;
}
//-----------------------------------------------
function SetViewTableDiv(tableName)
{
    var str = AdFindObjectID(tableName + 'Loc').style.display;
    if (str == 'block')
    {
        AdFindObjectID(tableName + 'Loc').style.display = "none";
        AdFindObjectID(tableName).src = "/Images/AdImgDown.gif";
    }
    else
    {
        AdFindObjectID(tableName + 'Loc').style.display = "block";
        AdFindObjectID(tableName).src = "/Images/AdImgUp.gif";
    }
    
}
//-----------------------------------------------
function AdFindObjectID(idName)
{
	return document.getElementById(idName);
}
function AdFindObjectName(strName)
{
	return document.getElementsByName(strName);
}
//-----------------------------------------------
function SetBlockAdWebServer(strName,intTabLength)
{
    try
    {
        var strDivName = strName.substring(0,strName.length-2);
        var AdDiv = AdFindObjectID(strDivName);
        for (var i = 1; i <= intTabLength; i++)
        {
            var stri = strDivName;
            if (i<10) 
                stri = strDivName+'0'+i;
            else 
                stri = strDivName+i;
            AdFindObjectID(stri).className = "tabgrey";
        }
        var strfile = AdFindObjectID(strName).headers;
        AdFindObjectID(strName).className = "tabgreen";
        AdDiv.innerHTML = AdGenerateHTML('/AdTest/XML/ad' + strfile + '.xml','/AdTest/XSLT/ad' + strfile + '.xsl');
    }
    catch(ex){}
}
//-----------------------------------------------
function SetBlockAdWebClient(strName,intTabLength)
{
    try
    {
        var strDivName = strName.substring(0,strName.length-2);
        for (var i = 1; i <= intTabLength; i++)
        {
            var stri = strDivName;
            if (i<10) 
                stri = strDivName+'0'+i;
            else 
                stri = strDivName+i;
            AdFindObjectID(stri).className = "tabgrey";
            AdFindObjectID(AdFindObjectID(stri).headers).style.display = "none";
        }
        AdFindObjectID(strName).className = "tabgreen";
        AdFindObjectID(AdFindObjectID(strName).headers).style.display = "block";
    }
    catch(ex){}
}
//----------------------------------------------
function AdGenerateHTML(XMLFile,XSLFile)
{
    try
    {
    	var xml;
    	var xsl;
        if (window.ActiveXObject)
        {
			xml = new ActiveXObject("Microsoft.XMLDOM");
            xsl = new ActiveXObject("Microsoft.XMLDOM");
        }
        else if (document.implementation && document.implementation.createDocument)
        {
            xml= document.implementation.createDocument("","",null);
            xsl= document.implementation.createDocument("","",null);
        }
        else
        {
            return 'Your browser cannot handle this script';
        }
        xml.async = false;
        xml.validateOnParse=true;
        xml.load(XMLFile);
        xsl.async = false;
        xsl.validateOnParse=true;
        xsl.load(XSLFile);
 	    return xml.transformNode(xsl);
        //-----------//-----------
 	}
    catch(errorobject)
    {
        return '<b>'+errorobject+'</b>';
    }
}